package io.bio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * 使用bio fileinputstream 进行文件的读取
 */
public class InputStreamDemo {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("G://test.txt")) {
            byte[] bytes = new byte[1024];
            int read;
            while((read = inputStream.read(bytes))!=-1){
                System.out.println(new String(bytes,0,read));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
